package io.github.talelin.latticy.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.github.talelin.latticy.model.UserDO;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.Date;

@Entity
@Getter
@Setter
@Where(clause = "delete_time is null and online = 1")
public class CommonJob extends BaseEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private Long putUserId;
    private Long getUserId;
    private Long projectId;
    private String putTitle;
    private String getTitle;
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "PRC")
    @Temporal(TemporalType.TIMESTAMP)
    private Date endTime;
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "PRC")
    @Temporal(TemporalType.TIMESTAMP)
    private Date expectedTime;
    private Boolean isGetting;
    private int status;
    private String remark;

    @JsonIgnore
    private Boolean online;

    @OneToOne
    @JoinColumn(name = "projectId", insertable = false, updatable = false)
    @NotFound(action= NotFoundAction.IGNORE)
    private Project project;

    @OneToOne
    @JoinColumn(name = "getUserId", insertable = false, updatable = false)
    @NotFound(action= NotFoundAction.IGNORE)
    private User getUser;
}
